package com.tiancheng.trade.payment.controller.api;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.payment.service.PaymentChannelService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import jakarta.validation.constraints.NotNull;

/**
 * 支付渠道
 */
@RestController
@RequestMapping("/api/paymentChannel")
@Validated
public class PaymentChannelApiController {

    @Resource
    PaymentChannelService paymentChannelService;

    /**
     * 获取所有支付渠道
     * @return
     */
    @GetMapping("/getAll")
    public Result getAll() {
        return Result.success(paymentChannelService.getAllConvert());
    }

    /**
     * 根据支付渠道编码获取支付渠道
     * @param channelCode 支付渠道编码
     * @return
     */
    @GetMapping("/getByChannelCode")
    public Result get(@NotNull @RequestParam("channel_code") String channelCode) {
        return Result.success(paymentChannelService.getByPaymentChannelCodeConvert(channelCode));
    }


}
